package id.co.rho.scoring.cid.client.mvc.upload;

import id.co.rho.scoring.cid.client.command.CommandDispatcherAsync;
import id.co.rho.scoring.cid.client.managed.request.ApplicationRequestFactory;
import id.co.rho.scoring.cid.client.mvc.AppEvents;
import id.co.rho.scoring.cid.client.security.Credential;

import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.google.inject.Inject;

public class UploadModelView extends View {

	private ApplicationRequestFactory requestFactory;
	private CommandDispatcherAsync dispatcher;
	private Credential credential;
	private UploadModelUI uploadModelUI;

	@Inject 
	public UploadModelView(ApplicationRequestFactory requestFactory,
			CommandDispatcherAsync dispacther, Credential credential,
			UploadModelUI uploadModelUI) {
		super(null);
		this.requestFactory = requestFactory;
		this.dispatcher = dispacther;
		this.credential = credential;
		this.uploadModelUI = uploadModelUI;
		controller = new ViewController();

	}
	
	@Override
	public void initialize() {
		super.initialize();
		uploadModelUI.initialize();
	}

	@Override
	protected void handleEvent(AppEvent event) {
		if (event.getType().equals(AppEvents.UploadModelEvent)) {
			uploadModelUI.show();
		}
	}
	
	private class ViewController extends Controller {
		private ViewController() {
			registerEventTypes(AppEvents.UploadModelEvent);
		}

		@Override
		public void handleEvent(AppEvent event) {
			forwardToView(UploadModelView.this, event);
		}
	}
	
	

}
